package com.gitee.swsk33.dbproduct.dao;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gitee.swsk33.dbentity.dataobject.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductDAO extends BaseMapper<Product> {

	/**
	 * 根据商品id查询其对应的所有订单id列表
	 *
	 * @param productId 商品id
	 * @return 订单id列表
	 */
	@Select("select `order_id` from `order_product` where `product_id` = #{productId}")
	@DS("bridge")
	List<Integer> selectOrderIds(int productId);


	/**
	 * 删除和某个商品关联的订单id记录
	 *
	 * @param productId 商品id
	 * @return 删除记录个数
	 */
	@Delete("delete from `order_product` where `product_id` = #{productId}")
	@DS("bridge")
	int deleteOrderIds(int productId);

}